<?php

namespace Api\Controller;
use Think\Controller;

class RegionController extends Controller {

    public function available_region(){
        $region = M('sys_configure')->where('configure_id=1')->find();
        $region_arr = (array)json_decode($region['configure_value']);

        $region_list = array();
        foreach ($region_arr as $k=>$v){
            if($v!="") {
                $region_info = M('region_list')->where('region_id=' . $v)->find();
                if ($region_info) {
                    $region_list[] = array(
                        'region_id' => $region_info['region_id'],
                        'region_name' => $region_info['region_name']
                    );
                }
            }
        }
        $this->ajaxReturn($region_list, 'JSON');
    }

}